package com.hzhjhh.view.manageView;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JToolBar;
import javax.swing.JTree;
import javax.swing.border.TitledBorder;
import javax.swing.tree.DefaultMutableTreeNode;

import com.hzhjhh.view.manageView.menus.MAccountMng;
import com.hzhjhh.view.manageView.menus.MExit;
import com.hzhjhh.view.manageView.menus.MFile;
import com.hzhjhh.view.manageView.menus.MPurchase;
import com.hzhjhh.view.manageView.menus.MQuery;
import com.hzhjhh.view.manageView.menus.MSoftAbout;
import com.hzhjhh.view.manageView.menus.MStorage;
import com.hzhjhh.view.manageView.menus.query.QueryMerchandiseInfo;
import com.hzhjhh.view.manageView.navigations.NavigationsInit;
import com.hzhjhh.view.manageView.navigations.RootMgInit;

/**
 * 后台进销存系统管理页面
 * 
 * @author Administrator
 *
 */
//@Getter
//@Setter
public class MainFrame extends JFrame {
	JPanel contentPane = new JPanel();
	JMenuBar jMenuBar1 = new JMenuBar();
	JMenu jMenuFile = MFile.init();
	JToolBar jToolBar = new JToolBar();
	JButton jButton1 = new JButton();
	JButton jButton2 = new JButton();
	JButton jButton3 = new JButton();
	ImageIcon image1 = new ImageIcon(MainFrame.class.getResource("/pictures/openFile.png"));
	ImageIcon image2 = new ImageIcon(MainFrame.class.getResource("/pictures/closeFile.png"));
	ImageIcon image3 = new ImageIcon(MainFrame.class.getResource("/pictures/help.png"));
	JLabel statusBar = new JLabel();
	JScrollPane jScrollPane1 = new JScrollPane();
	JTree jTree1 = new JTree();
	JMenuItem miExit = MExit.init();
	JMenu mPurchase = MPurchase.init();
	JMenu mStorage = MStorage.init();
	JMenu mAccountMng = MAccountMng.init();
	JMenu mAuthorInfo = MSoftAbout.init();
	JMenu mQuery = MQuery.init(this);
	JMenuItem miSaleStatistics = new JMenuItem();
	JMenu mQueryMerchandiseInfo = QueryMerchandiseInfo.init(this);
	JScrollPane jScrollPane2 = new JScrollPane();
	JTable jTable1 = new JTable();
	TitledBorder titledBorder1 = new TitledBorder("");

	public MainFrame() {
		try {
			setDefaultCloseOperation(EXIT_ON_CLOSE);
			jbInit("超市进销存系统");
		} catch (Exception exception) {
			exception.printStackTrace();
		}
	}

	/**
	 * Component initialization.
	 *
	 * @throws java.lang.Exception
	 */
	private void jbInit(String title) throws Exception {
		contentPane = (JPanel) getContentPane();
		contentPane.setLayout(null);
		setSize(new Dimension(930, 600));
		setTitle(title);
		statusBar.setText(" ");
		statusBar.setBounds(new Rectangle(0, 585, 800, 15));
		// 设置树
		DefaultMutableTreeNode root = RootMgInit.init();

		contentPane.setBackground(Color.pink);
		
		jScrollPane2.setBorder(BorderFactory.createLineBorder(Color.black));
		jScrollPane2.setBounds(new Rectangle(167, 93, 750, 435));

		// 初始化树
		jTree1 = NavigationsInit.init(this);
//		jTree1.addTreeSelectionListener(new MainFrame_jTree1_treeSelectionAdapter(this));
		jToolBar.setBounds(new Rectangle(0, 0, 800, 29));
		jScrollPane1.setBounds(new Rectangle(13, 93, 152, 435));
		jMenuBar1.add(jMenuFile);
		jMenuFile.add(miExit);
		jMenuBar1.add(mPurchase);
		jMenuBar1.add(mStorage);
		jMenuBar1.add(mAccountMng);
		jMenuBar1.add(mQuery);
		jMenuBar1.add(mAuthorInfo);
		setJMenuBar(jMenuBar1);
		jButton1.setIcon(image1);
		jButton1.setToolTipText("Open File");
		jButton2.setIcon(image2);
		jButton2.setToolTipText("Close File");
		jButton3.setIcon(image3);
		jButton3.setToolTipText("Help");
		jToolBar.add(jButton1);
		jToolBar.add(jButton2);
		jToolBar.add(jButton3);
		contentPane.add(jToolBar, null);
		contentPane.add(statusBar, null);
		contentPane.add(jScrollPane1);
		contentPane.add(jScrollPane2);
		jScrollPane2.getViewport().add(jTable1);
		jScrollPane1.getViewport().add(jTree1);
	}

	/**
	 * Help | About action performed.
	 *
	 * @param actionEvent
	 *            ActionEvent
	 */
	void jMenuHelpAbout_actionPerformed(ActionEvent actionEvent) {
		MainFrameAboutBox dlg = new MainFrameAboutBox(this);
		Dimension dlgSize = dlg.getPreferredSize();
		Dimension frmSize = getSize();
		Point loc = getLocation();
		dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
		dlg.setModal(true);
		dlg.pack();
		dlg.setVisible(true);
	}



	public JTree getjTree1() {
		return jTree1;
	}

	public void setjTree1(JTree jTree1) {
		this.jTree1 = jTree1;
	}

	public JScrollPane getjScrollPane2() {
		return jScrollPane2;
	}

	public void setjScrollPane2(JScrollPane jScrollPane2) {
		this.jScrollPane2 = jScrollPane2;
	}

	public JTable getjTable1() {
		return jTable1;
	}

	public void setjTable1(JTable jTable1) {
		this.jTable1 = jTable1;
	}
	

}
